/*
 * @Author: yangni 920556271@qq.com
 * @Date: 2023-12-07 09:26:03
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2023-12-20 10:43:44
 * @FilePath: /yt-devops/lib/pages/tasks/component/wrap_widget.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yt_devops/components/card_wrap.dart';
import 'package:yt_devops/styles/styles.dart';

class WrapWidget extends StatelessWidget {
  final Widget? child;
  final String? title;
  final String? subTitle;
  final bool isRequire;
  final TextStyle? titleStyle;
  final EdgeInsets? padding;
  const WrapWidget(
      {super.key,
      this.child,
      this.title,
      this.subTitle,
      this.isRequire = false,
      this.padding,
      this.titleStyle});

  @override
  Widget build(BuildContext context) {
    return CardWrap(
      padding: padding ?? EdgeInsets.fromLTRB(16.w, 0, 16.w, 14.h),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          if (title != null)
            Container(
              height: 48.h,
              alignment: Alignment.centerLeft,
              child: Text.rich(
                TextSpan(
                  text: isRequire ? '*' : '',
                  style: TextStyles.f14.warningColorStyle,
                  children: [
                    TextSpan(
                        text: title,
                        style: titleStyle ?? TextStyles.f18.mediumStyle),
                    if (subTitle != null)
                      TextSpan(text: subTitle, style: TextStyles.lf12)
                  ],
                ),
              ),
            ),
          if (child != null) child!
        ],
      ),
    );
  }
}
